package com.ruoyi.system.controller;

import java.util.List;


import com.ruoyi.system.model.dto.BankClearQueryDto;
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.BankPlatform;
import com.ruoyi.system.service.IBankPlatformService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 银行账户平台Controller
 * 
 * @author zhangjf
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/platform")
public class BankPlatformController extends BaseController
{
    @Autowired
    private IBankPlatformService bankPlatformService;


    /**
     * 查询银行账户平台列表
     */
    @RequiresPermissions("system:platform:list")
    @GetMapping("/list")
    public TableDataInfo list(BankPlatform bankPlatform)
    {
        List<BankPlatform> list = bankPlatformService.selectBankPlatformList(bankPlatform);
        return getDataTable(list);
    }

    /**
     * 导出银行账户平台列表
     */
    @RequiresPermissions("system:platform:export")
    @Log(title = "银行账户平台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankPlatform bankPlatform)
    {
        BankClearQueryDto dto = new BankClearQueryDto();
        dto.setStartDate("20250930");
        dto.setEndDate("20250930");
        bankPlatformService.bankClearQuery(dto);
        List<BankPlatform> list = bankPlatformService.selectBankPlatformList(bankPlatform);
        ExcelUtil<BankPlatform> util = new ExcelUtil<BankPlatform>(BankPlatform.class);
        util.exportExcel(response, list, "银行账户平台数据");
    }

    /**
     * 获取银行账户平台详细信息
     */
    @RequiresPermissions("system:platform:query")
    @GetMapping(value = "/{bankPlatformAcctid}")
    public AjaxResult getInfo(@PathVariable("bankPlatformAcctid") Long bankPlatformAcctid)
    {
        return success(bankPlatformService.selectBankPlatformByBankPlatformAcctid(bankPlatformAcctid));
    }

    /**
     * 新增银行账户平台
     */
    @RequiresPermissions("system:platform:add")
    @Log(title = "银行账户平台", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankPlatform bankPlatform)
    {
        return toAjax(bankPlatformService.insertBankPlatform(bankPlatform));
    }

    /**
     * 修改银行账户平台
     */
    @RequiresPermissions("system:platform:edit")
    @Log(title = "银行账户平台", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankPlatform bankPlatform)
    {
        return toAjax(bankPlatformService.updateBankPlatform(bankPlatform));
    }

    /**
     * 删除银行账户平台
     */
    @RequiresPermissions("system:platform:remove")
    @Log(title = "银行账户平台", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bankPlatformAcctids}")
    public AjaxResult remove(@PathVariable Long[] bankPlatformAcctids)
    {
        return toAjax(bankPlatformService.deleteBankPlatformByBankPlatformAcctids(bankPlatformAcctids));
    }

    /**
     * 查询平台账户余额
     * @param
     * @return
     */
    @PermitAll
    @GetMapping(value = "/getBalance")
    public AjaxResult custAcctIdBalanceQuery(@RequestParam String sxfSubacct ){


        return success(bankPlatformService.custAcctIdBalanceQuery(sxfSubacct));
    }


}
